function[] = discriminantF()


classes=[1,2,2,3,5,6,4,2,5;2,1,3,1,2,3,4,1.75,3];
groups=[1,1,1,1,2,2,2,3,4];

subplot(2,2,1);
gscatter(classes(1,:),classes(2,:),groups,'brmc','xo');
hold on;
plot([2,5],[1.75,3]);
hold on;
ezplot('-1/4*x^2-23/6*x-11/3*y+197/8+0.5*log(0.75)-0.5*log(0.5)');
hold on;
legend('A','B','mA','mB','Location','NorthEast');
[X,Y] = meshgrid(linspace(-2,13),linspace(-2,6));
X = X(:); Y = Y(:);
[C,err,P,logp,coeff] = classify([X Y],[1 2; 2 1; 2 3; 3 1; 5 2; 6 3; 4 4], [1 1 1 1 2 2 2], 'mahalanobis');
K = coeff(1,2).const;
L = coeff(1,2).linear;
Q = coeff(1,2).quadratic;
f = @(x,y) K + [x y]*L + sum(([x y]*Q) .* [x y], 2);

axis([-2 13 -2 6]);

subplot(2,2,3);
ezplot(f,[-2 13 -2 6]);
title('mahalanobis (individual covariance m.)');
axis([-2 13 -2 6]);

subplot(2,2,2);
gscatter(classes(1,:),classes(2,:),groups,'brmc','xo');
hold on;
plot([2,5],[1.75,3]);
hold on;
ezplot('3*x+1.25*y-13.46875');
legend('A','B','mA','mB','Location','NorthEast');
[C,err,P,logp,coeff] = classify([X Y],[1 2; 2 1; 2 3; 3 1; 5 2; 6 3; 4 4], [1 1 1 1 2 2 2], 'diagLinear');
K = coeff(1,2).const;
L = coeff(1,2).linear;
f = @(x,y) K + [x y]*L;
axis([-2 13 -2 6]);

subplot(2,2,4);
ezplot(f,[-2 13 -2 6]);
title('linear (identity m.)');
axis([-2 13 -2 6]);


